package com.gong.servlet;

import com.gong.constants.UserConstants;
import com.gong.pojo.User;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @ClassName: LogoutServlet
 * @Description: TODO
 * @Author: 。。。
 * @Data: 2021/10/209:38
 * @Version: 1.0
 **/
public class LogoutServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.getSession().removeAttribute(UserConstants.USER_SESSION);
		resp.sendRedirect(req.getContextPath() + "/login.jsp");

		System.out.println("req.getContextPath() ==" + req.getContextPath());
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
